﻿Public Class CommonFunctions
    Public Shared Function YearList() As Collection
        Dim cl As New Collection
        For i As Int16 = -2 To 3
            cl.Add(Now.Year + i)
        Next
        Return cl
    End Function

    Public Shared Function MonthList() As Collection
        Dim cl As New Collection
        cl.Add("Jan", "1")
        cl.Add("Feb", "2")
        cl.Add("Mar", "3")
        cl.Add("Apr", "4")
        cl.Add("May", "5")
        cl.Add("Jun", "6")
        cl.Add("Jul", "7")
        cl.Add("Aug", "8")
        cl.Add("Sep", "9")
        cl.Add("Oct", "10")
        cl.Add("Nov", "11")
        cl.Add("Dec", "12")
        Return cl
    End Function

    Public Function num_to_word(ByVal strAmt As String) As String
        num_to_word = Nothing
        Try
            Dim txtWords As String
            Dim arrOneToNineteen() = {"One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "}
            Dim arrTens() = {"Twenty ", "Thirty ", "Fourty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "}
            Dim arrSuffixDenom() = {"Hundred ", "Thousand ", "Lakh ", "Crore "}
            Dim effLen As Long, totLen As Long, temp As Byte, strTemp As String = Nothing

            strAmt = Format(Val(Microsoft.VisualBasic.Left(strAmt, 9)), "0.00")
            'txtFigure = Microsoft.VisualBasic.Left(txtFigure, 9)

            totLen = Len(strAmt) - 3
            effLen = totLen

            '55,13,22,1,23 - fifty five crore thirteen lakhs twenty thousand one hundred twenty three.
            '98 76 54 3 21 - positions
            Do While effLen <> 0
                Select Case effLen
                    Case 1, 3, 4, 6, 8
                        temp = Int(Val(Mid(strAmt, (totLen - effLen + 1), 1)))
                        If temp Then
                            strTemp = strTemp + arrOneToNineteen(Microsoft.VisualBasic.Left(temp, 1) - 1)
                            If Not (effLen = 1) Then strTemp = strTemp + arrSuffixDenom(Int(effLen / 2) - 1)
                        End If
                        effLen = effLen - 1
                    Case 2, 5, 7, 9
                        temp = Int(Val(Mid(strAmt, (totLen - effLen + 1), 2)))
                        If temp Then
                            If temp > 19 Then
                                strTemp = strTemp + arrTens(Microsoft.VisualBasic.Left(temp, 1) - 2)
                                If Int(Microsoft.VisualBasic.Right(temp, 1)) Then strTemp = strTemp + arrOneToNineteen(Microsoft.VisualBasic.Right(temp, 1) - 1)
                            Else
                                strTemp = strTemp + arrOneToNineteen(Microsoft.VisualBasic.Left(temp, 2) - 1)
                            End If
                            If Not (effLen = 2) Then strTemp = strTemp + arrSuffixDenom(Int(effLen / 2) - 1)
                        End If
                        effLen = effLen - 2
                End Select
            Loop
            txtWords = strTemp
            num_to_word = txtWords
        Catch ex As Exception
            Throw ex
        End Try
    End Function


End Class

Public Enum FormAction
    None = 0
    ADD = 1
    EDIT = 2
    DELETE = 3
    CANCEL = 4
    SEARCH = 5
End Enum

Enum LookItems
    BillCharges
    CustomerType
    ItemCategory
    Model
    UOM
End Enum